using ServiceStack.DataAnnotations;
using System;
using System.ComponentModel;
using System.Reflection;
namespace ServiceStack
{
	public static class AttributeExtensions
	{
		public static string GetDescription(this Type type)
		{
			ApiAttribute apiAttribute = type.FirstAttribute<ApiAttribute>();
			if (apiAttribute != null)
			{
				return apiAttribute.Description;
			}
			System.ComponentModel.DescriptionAttribute descriptionAttribute = type.FirstAttribute<System.ComponentModel.DescriptionAttribute>();
			if (descriptionAttribute != null)
			{
				return descriptionAttribute.Description;
			}
			ServiceStack.DataAnnotations.DescriptionAttribute descriptionAttribute2 = type.FirstAttribute<ServiceStack.DataAnnotations.DescriptionAttribute>();
			if (descriptionAttribute2 != null)
			{
				return descriptionAttribute2.Description;
			}
			return null;
		}
		public static string GetDescription(this MemberInfo mi)
		{
			ApiMemberAttribute apiMemberAttribute = mi.FirstAttribute<ApiMemberAttribute>();
			if (apiMemberAttribute != null)
			{
				return apiMemberAttribute.Description;
			}
			System.ComponentModel.DescriptionAttribute descriptionAttribute = mi.FirstAttribute<System.ComponentModel.DescriptionAttribute>();
			if (descriptionAttribute != null)
			{
				return descriptionAttribute.Description;
			}
			ServiceStack.DataAnnotations.DescriptionAttribute descriptionAttribute2 = mi.FirstAttribute<ServiceStack.DataAnnotations.DescriptionAttribute>();
			if (descriptionAttribute2 != null)
			{
				return descriptionAttribute2.Description;
			}
			return null;
		}
		public static string GetDescription(this ParameterInfo pi)
		{
			System.ComponentModel.DescriptionAttribute descriptionAttribute = pi.FirstAttribute<System.ComponentModel.DescriptionAttribute>();
			if (descriptionAttribute != null)
			{
				return descriptionAttribute.Description;
			}
			ServiceStack.DataAnnotations.DescriptionAttribute descriptionAttribute2 = pi.FirstAttribute<ServiceStack.DataAnnotations.DescriptionAttribute>();
			if (descriptionAttribute2 != null)
			{
				return descriptionAttribute2.Description;
			}
			return null;
		}
	}
}
